<template>
    <el-tabs v-model="active" type="border-card" @tab-click="tabClick">
        <el-tab-pane label="病历诊断" name="0">
            <clinic-medical-record-view ref="clinicMedicalRecordViewRef"/>
        </el-tab-pane>
        <el-tab-pane label="检查" name="1">
            <!-- 检查单查看 -->
            <clinic-exam-view ref="clinicExamViewRef"/>
        </el-tab-pane>
        <el-tab-pane label="检验" name="2">
            <!-- 检验单查看 -->
            <clinic-lab-view ref="clinicLabViewRef"/>
        </el-tab-pane>
        <el-tab-pane label="处方" name="3">
            <!-- 处方查看 -->
            <clinic-prescription-view ref="clinicPrescriptionViewRef"/>
        </el-tab-pane>
    </el-tabs>
</template>
<script lang="ts" setup>
import {useUserStoreHook} from "@/store/modules/user.ts";
import {useDictStoreHook} from "@/store/modules/dict.ts";
import clinicLabView from "@/views/patient/patientTable/checkTheMedicalRecord/clinicLabView.vue";
import clinicPrescriptionView from "@/views/patient/patientTable/checkTheMedicalRecord/clinicPrescriptionView.vue";
import clinicExamView from "@/views/patient/patientTable/checkTheMedicalRecord/clinicExamView.vue";
import clinicMedicalRecordView from "@/views/patient/patientTable/checkTheMedicalRecord/clinicMedicalRecordView.vue";

const useUserStore = useUserStoreHook();
// 登录用户信息
const userInfo = <UserInfoBusi>useUserStore.user.userInfo;
const dictStore = useDictStoreHook();
let dictDataMap = ref(
    dictStore.isTypeGetData("charge_flag_dict", 'dose_unit', 'spec_unit',
        'charge_flag_dict', 'order_type', 'new_order_type', 'order_status', 'billing_attr', 'return_drug_status'
    )
);
const clinicExamViewRef = ref()
const clinicLabViewRef = ref()
const clinicPrescriptionViewRef = ref()
const clinicMedicalRecordViewRef = ref()

const active = ref('0')
const queryParams = ref<any>({
    patientId: "",
    clinicId: "",
    orgId: userInfo.orgId,
    name: "",
    itemName: '',
    inoroutFlag: '1',
    confirmFlag: '1'
})

/**
 * 父组件加载初始化方法
 */
function initOpen(obj: any) {
    active.value = '0'
    queryParams.value.clinicId = obj.id;
    queryParams.value.patientId = obj.patientId;
    nextTick(() => {
        clinicMedicalRecordViewRef.value.getClinicRecordList(queryParams.value.clinicId)
    })

}


/**
 * tab页点击事件
 * @param obj
 */
function tabClick(obj: any) {
    const objThis = toRaw(obj)
    if (objThis.props.name === '1') {
        nextTick(() => {
            clinicExamViewRef.value.getExamApplyList(queryParams.value.clinicId)
        })

    } else if (objThis.props.name === '2') {
        nextTick(() => {
            clinicLabViewRef.value.getLabApplyList(queryParams.value.clinicId)
        })

    } else if (objThis.props.name === '3') {
        nextTick(() => {
            clinicPrescriptionViewRef.value.getPrescriptionApplyList(queryParams.value.clinicId)
        })

    } else if (objThis.props.name === '0') {
        nextTick(() => {
            clinicMedicalRecordViewRef.value.getClinicRecordList(queryParams.value.clinicId)
        })
    } else if (objThis.props.name === '4') {


    }
}

defineExpose({
    initOpen
})
</script>


<style scoped>
:deep(.el-table .success-row) {
    --el-table-tr-bg-color: var(--el-color-success-light-9);
}

:deep(.el-tabs__content) {
    padding: 0;
}

</style>
